package org.chickymate.client.view.panel;

import org.chickymate.client.model.ImageDTO;
import org.chickymate.client.model.ModelDTO;

import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.Widget;

public class ImageView extends AbstractModelView {

	public ImageView(ModelDTO model) {
		super(model);
	}
	
	@Override
	protected Widget getContent(ModelDTO model) {
		ImageDTO image = (ImageDTO)model;
		return createImage(image.getImageUrl());
	}

	@Override
	protected String getDateContent(ModelDTO model) {
		return "With votes : ";
	}
	
	private Widget createImage(String imageUrl) {
		FlowPanel panel = new FlowPanel();
		Image image = new Image();
		image.setUrl(imageUrl);
		panel.add(image);
		panel.add(createUrlAnchor(imageUrl));
		return panel;
	}

}
